from marshmallow import fields
from gis.common.django_ext.forms import PaginationSchema, BaseSchema, EnumField
from itpay.core.mch.const import MchType


class AddMchSchema(BaseSchema):
    name = fields.String(required=True)
    enable = fields.Boolean()
    create_order_url = fields.String(required=True)
    recharge_order_url = fields.String(required=True)
    chase_order_url = fields.String(required=True)
    get_charge_info_url = fields.String(required=True)
    fail_order_url = fields.String(required=True)
    mch_type = EnumField(MchType)


class ListMchSchema(PaginationSchema):
    enable = fields.Boolean()
    mch_type = EnumField(MchType)


class UpdateMchSchema(BaseSchema):
    name = fields.String()
    enable = fields.Boolean()
    create_order_url = fields.String(allow_none=True)
    recharge_order_url = fields.String(allow_none=True)
    chase_order_url = fields.String(allow_none=True)
    get_charge_info_url = fields.String(allow_none=True)
    fail_order_url = fields.String(allow_none=True)
